#ifndef CART_H
#define CART_H
#include "Good.h"
#include <vector>
#include <sstream>
class Server;
class Interface;
class cart {
  friend class Server;
  friend class Interface;

public:
  cart():money(0) {}
  cart(const cart &c) {
    goods = c.goods;
    money = c.money;
  }
  int len() { return goods.size(); }
  double cost() { return money; }
  good &operator[](int index) { return goods[index]; }
  void add_good(good a, bool sold = 0);
  int del_good(const good &a, int num = -1);
  // mode : 0 for no owner, 1 for has owner.
  void to_file(std::ofstream &fs, int mode = 0);
  void from_file(std::ifstream &fs, int mode = 0);

private:
  std::vector<good> goods;
  double money;
};

typedef cart inventory;
#endif